<?php

/**
 * LEAGUEMan
 * 
 * Copyright (C) 2007 Marko Bischof
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

$teams	= $this->project->getTeams("team_id");
$rounds = $this->project->getRounds("ordering"); 

?>

<table class="contentpaneopen">
	<tr>
		<td width="1%" class="sectiontableheader">&nbsp;</td>
		<td width="10%" class="sectiontableheader"><?php echo _LM_DATE; ?></td>
		<td width="30%" class="sectiontableheader"><?php echo _LM_HOME; ?></td>
		<td class="sectiontableheader"></td>
		<td width="30%" class="sectiontableheader"><?php echo _LM_AWAY; ?></td>
		<td width="24%" class="sectiontableheader"><?php echo _LM_RESULT; ?></td>
		<td width="5%" class="sectiontableheader">&nbsp;</td>
	</tr>
 
<?php

$goals	= 0;
$v		= 0;

foreach($this->matches as $match){

	if($this->mode > 0){
		if($this->mode == 1 && $match->team2_id == $this->team->getID()) continue;
		if($this->mode == 2 && $match->team1_id == $this->team->getID()) continue;
	}
	
	if(is_numeric($match->match_result_0_1) && is_numeric($match->match_result_0_2)){
		$goals = $goals + $match->match_result_0_1 + $match->match_result_0_2;
		$v++;
	}
		
?>
	<tr class="<?php $this->plugin("toggle", "sectiontableentry1", "sectiontableentry2");?>">
		<td><?php $this->plugin("leagueman_get_roundinfo_link", $rounds, $match->match_project, $match->match_round, 0, $this->Itemid)?></td>
		<td><?php $this->plugin("leagueman_get_match_datetime", $match, "%d.%m.%Y");?></td>
		<td><?php $this->plugin("leagueman_get_teaminfo_link", $teams, $match->team1_id, $match->team1_name, $this->team->getID(), $this->Itemid);?></td>
		<td>-</td>
		<td><?php $this->plugin("leagueman_get_teaminfo_link", $teams, $match->team2_id, $match->team2_name, $this->team->getID(), $this->Itemid);?></td>
		<td nowrap="nowrap">
			<?php $this->plugin("leagueman_get_match_result", $match, 0);?>&nbsp;
			<?php $this->plugin("leagueman_get_match_result", $match, $this->project->getParam("cnt_chapters", 0));?>
		</td>
		<td>{leagueman_discussion_link type="match" m="<?php echo $match->match_id;?>"}</td>
	</tr>
<?php

}
	
?>
	<tr>
		<td class="sectiontableheader" colspan="7">
			<div align="center"><?php printf("%s: %s (%1.2f %s)", _LM_TOTALGOALS, $goals, $this->splugin("leagueman_get_avg", $goals, $v), _LM_PERMATCH); ?></div>
		</td>
	</tr>

</table>